<?php

namespace Kangcg\Application\Validate\Rules;

use Kangcg\Application\Validate\Validator;
use Kangcg\Helper\Validate\Base;

class Required implements RuleInterface
{
    use RuleTrait;

    protected function beforeRun(&$value) : bool{
        return true;
    }

    protected function afterRun(&$value, string $field, array $input, Validator $validator)
    {
        if($value === null || $value === ''){
            $validator->setError($this->getMessage($field));
            return false;
        }
    }
}
